//
//  SettingPasswordViewController.m
//  CarUser
//
//  Created by ayi on 2018/12/26.
//  Copyright © 2018 王森林. All rights reserved.
//

#import "SettingPasswordViewController.h"

@interface SettingPasswordViewController ()

@property (weak, nonatomic) IBOutlet UITextField *nametextf;
@property (weak, nonatomic) IBOutlet UITextField *passwordtextf;
@property (weak, nonatomic) IBOutlet UIButton *nextBtn;

@end

@implementation SettingPasswordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"设置昵称及密码";
    
    self.nextBtn.layer.masksToBounds = YES;
    self.nextBtn.layer.cornerRadius = 22;
    
    self.passwordtextf.secureTextEntry = YES;
    [self.nametextf setValue:Common_TextLowColor forKeyPath:@"_placeholderLabel.textColor"];
    [self.passwordtextf setValue:Common_TextLowColor forKeyPath:@"_placeholderLabel.textColor"];
}


- (IBAction)registerAction:(id)sender
{
    
    
    if ([CommonMethod isBlankString:self.passwordtextf.text]) {
         [SVProgressHUD showErrorWithStatus:@"密码不能为空"];
        return ;
    }
    
    if ([CommonMethod isBlankString:self.nametextf.text]) {
        [SVProgressHUD showErrorWithStatus:@"昵称不能为空"];
        return ;
    }
    
    
    NSDictionary *params = @{
                             @"FKEY":[CommonMethod createMD5Key:@"USERNAME"],
                             @"USERNAME":self.mobile,
                             @"ROLEID":@"1",
                             @"PASSWORD":self.passwordtextf.text,
                             @"NAME":self.nametextf.text
                             };
    
    dispatch_async(dispatch_get_main_queue(), ^{
        [SVProgressHUD showWithStatus:nil];
    });
    
    [[ZY_AfnNetManager shareInstance]postWithURL:Car_API_Register params:params md5Paraname:nil success:^(id  _Nullable response) {
     
        dispatch_async(dispatch_get_main_queue(), ^{
            [SVProgressHUD dismiss];
        });
        dispatch_async(dispatch_get_main_queue(), ^{
            [SVProgressHUD showInfoWithStatus:@"您已成功注册,请登录"];
            //                [SVProgressHUD dismissWithDelay:10];
        });
        [self.navigationController popToRootViewControllerAnimated:YES];
        
    } fail:^(NSError * _Nonnull error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [SVProgressHUD showErrorWithStatus:error.localizedDescription];
        });
      
    }];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
